<?php  include  $this->admin_tpl('header'); ?>
<link rel="stylesheet" type="text/css" href="<?php echo JS_PATH;?>EasyUI/themes/haidaoblue/easyui.css">
<link rel="stylesheet" type="text/css" href="<?php echo JS_PATH;?>EasyUI/themes/icon.css">
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/hd_default_config.js"></script>
<div class="content">
	<div class="site">
	<?php echo C('site_name')?> <a href="#">订单管理</a> > 订单列表
	</div>
	<span class="line_white"></span>
	<div class="goods mt10">
		<div class="search_ind">
			<input type="hidden" name="m" value="<?php echo GROUP_NAME ?>">
			<input type="hidden" name="c" value="<?php echo MODULE_NAME ?>">
			<input type="hidden" name="a" value="<?php echo ACTION_NAME ?>">
            <span style="margin-right: 10px;">状态</span>
				<select name='status_type' id='group_combbox' class="easyui-combobox" data-options="editable:false,panelHeight:'auto'" style="height: 26px; width:100px;">
                </select>
                <span style="margin-right: 10px;">开始时间 </span>
                <input class="easyui-datebox" name="start" id="start">
                <span style="margin-right: 10px;">至</span>
                <input class="easyui-datebox" name="end" id="end" validType="md['#start']">
			<span style="margin-right: 10px;">订单搜索 </span>
			<input id="keyword" class="easyui-textbox" name="keyword" style="width:210px;height: 26px;" prompt="输入单号/消费者/商家帐号/手机均可查询">
			<a id="search" href="#" class="easyui-linkbutton" style="height: 26px;padding-right: 10px;">查询</a>
		</div>
		<div class="login mt10" style="border: none;border-right: 1px solid #e6e6e6;">
			<table id="order_list_grid" style="width:100%;"></table>
		</div>
		<div class="clear"></div>
		<?php include $this->admin_tpl('copyright') ?>
	</div>
</div>
	<script type="text/javascript">
		$(function() {
		//批量操作
			$(".batch").hover(function() {
				$(this).find("p").show();
				}, function() {
				$(this).find("p").hide();
			});
		})
		//改变状态架
		function corderstatus(ftype,val) {
			var arr = [];
			$("input[name='selid[]']:checked").each(function() {
				arr.push($(this).val());
			});
			if (arr.length == 0) {
				alert('请选择操作项目');
				return false;
			}
			$.post("<?php echo U('AdminOrder/ajax_status');?>", {"ftype":ftype ,"id": arr.toString(), "val": val}, function(data) {
				if (data.status == 1) {
				location.reload();
				}
			})
		}
		//切换
		$(function() {
			var tabTitle = ".mt10 dt p a";
			$(tabTitle).click(function(){
				$(this).siblings("a").removeClass("hover").end().addClass("hover");
			});
		});
	</script> 
	<!--表格js-->
	<script type="text/javascript">
	var dom = $('#order_list_grid');
	var pageSize = <?php echo PAGE_SIZE?>;
	var dataurl = '<?php echo U('scoreorder')?>';
	var delurl = '<?php echo U('delete')?>';
	var editurl = '<?php echo U('edit')?>';
	var imgpach = '<?php echo IMG_PATH;?>';
	var type = <?php echo $type?>;
	var keyword = '<?php echo $keyword?>';
	var user_id = <?php echo $user_id?>;
	$(function(){
		dom.datagrid({
			url:dataurl, 
			striped:true,
			width:'100%',
			title:"统计概览",  
			checkOnSelect:false,
			fitColumns:true,
			toolbar:[
				{
					id:'exportrows',
					text:'导出',
					iconCls:'icon-export',
				},'-'
			],
			frozenColumns:[[
				{field:'id',checkbox:true}
			]],
			queryParams:{
				type:type,
				keyword:keyword,
				user_id:user_id
			},
			scrollbarSize:0,
			pagination:true,
			pageSize:pageSize,
			pageList: [pageSize,pageSize*4,pageSize*8,pageSize*16,pageSize*32,pageSize*64],
			//可以设置每页记录条数的列表 
			columns:[[
			{field:'payorder',title:'订单号',width:'10%',halign:'center',align:'center'},
			{field:'dateline',title:'下单时间',width:'10%',align:'center',sortable:false,
				formatter:function(value,row,index){  
					return $.fn.datebox.defaults.timeformat(value);
				}
			},
			{field:'sellname',title:'商家帐号',width:'8%',halign:'center',align:'center',sortable:true},
			{field:'username',title:'消费者帐号',width:'8%',halign:'center',align:'center',sortable:true},
			{field:'buymobile_phone',title:'消费者手机号',width:'10%',halign:'center',align:'center',sortable:true},
			{field:'info',title:'商品信息',width:'32%',halign:'center',align:'center',sortable:true},
			{field:'pnum',title:'购买数量',width:'5%',halign:'center',align:'center',sortable:true},
			{field:'money',title:'订单金额',width:'10%',halign:'center',align:'center',sortable:false,
				formatter:function(value,row,index){
					return value+"元";
				}
			},
			{field:'status',title:'订单状态',width:'5%',halign:'center',align:'center',
				formatter:function(value,row,index){
					if(value == 0){
						delivery_text = '<font class="red">未做单</font>';
					}else{
						delivery_text = '已做单';
					}
					return delivery_text;
				}
			},
			]],onLoadSuccess:function(data){
				$(".panel-title").html(data.title);
				var group = data.status_type;
				group.unshift({"id":"","name":"请选择"})
				$('#group_combbox').combobox({
					data:group,
					valueField:'id',
					textField:'name'
				});
			}
		});
		$('#exportrows').bind('click', function(){
			var queryParams = dom.datagrid('options').queryParams;
			queryParams.status = $('#group_combbox').combobox('getValue');
			queryParams.start = $('#start').datebox('getValue');
			queryParams.end = $('#end').datebox('getValue');
			queryParams.keyword = $("#keyword").val();
			window.location.href="/index.php?c=admin_order&a=scoreorder&act=excel&status="+queryParams.status+"&start="+queryParams.start+"&end="+queryParams.end+"&keyword="+queryParams.keyword;
		});
		//回车查询
		$('#keyword').textbox('textbox').bind('keydown',function (e) {
			if (e.keyCode == 13) {
				$('#search').trigger('click');
			}
		});
		// 打印订单
		$('#printdelivery').bind('click', function(){
			var ids = [];
			var rows = dom.datagrid('getChecked');
			for(var i=0; i<rows.length; i++){
				ids.push(rows[i].id);
			}
			if (ids.length > 0){
				console.debug(rows);
			}else{
				$.messager.alert('友情提示','请勾选您要打印的记录');
				return false;
			}
		});
	});
	//增加查询参数，重新加载表格
	$('#search').bind('click',function (){
		var queryParams = dom.datagrid('options').queryParams;
		//查询参数直接添加在queryParams中
		queryParams.status = $('#group_combbox').combobox('getValue');
		queryParams.start = $('#start').datebox('getValue');
		queryParams.end = $('#end').datebox('getValue');
		queryParams.keyword = $("#keyword").val();
		dom.datagrid('options').queryParams = queryParams;
		dom.datagrid('reload');
	})
</script>